package com.aurora.source.authority.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.aurora.source.R;
import com.aurora.source.authority.bean.AuthDataBean;
import com.aurora.source.base.BaseRecyclerAdapter;
import com.aurora.source.base.CommonHolder;

import butterknife.BindView;

/**
 * @author: ww
 * @description:
 * @date: 2018/9/10
 */
public class SelectedAuthAdapter extends BaseRecyclerAdapter<AuthDataBean> {
    @Override
    public CommonHolder<AuthDataBean> setViewHolder(ViewGroup parent) {
        return new MyHolder(parent.getContext(), parent);
    }

    class MyHolder extends CommonHolder<AuthDataBean> {

        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.iv_delete)
        ImageView ivDelete;

        public MyHolder(Context context, ViewGroup root) {
            super(context, root, R.layout.item_select_auth_data);
        }

        @Override
        public void bindData(AuthDataBean authDataBean, int positon) {
            ivDelete.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int position = getLayoutPosition();
                    AuthDataBean deleteData = getData(position);
                    deleteData.setSelected(false);
                    deletPosition(position);
                    if(onItemClickListener!=null){
                        onItemClickListener.onClick(position,deleteData);
                    }

                }
            });
        }
    }
}
